﻿using System;
namespace Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg {
    
    
    [global::Xtee.Core.Attributes.XmlTypeAttribute(Name="xbrlesita_audiitor", Namespace="http://producers.arireg.xtee.riik.ee/producer/arireg", Target=typeof(XbrlesitaAudiitor))]
    public class XbrlesitaAudiitorSerializer : global::Xtee.Core.Types.AbstractXteeSerializable {
        
        protected IXbrlesitaAudiitor clazz;
        
        public XbrlesitaAudiitorSerializer(IXbrlesitaAudiitor clazz) {
            this.clazz = clazz;
        }
        
        public override void WriteXml(global::Xtee.Core.IXteeXmlWriter Writer) {
            base.WriteXml(Writer);
            Writer.WriteStartElement("isikukood");
            if (clazz.Isikukood!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Isikukood))).ToString());
            }
            else {
                Writer.WriteAttributeString("xsi", "nil", null, "1");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("audiitorettevotja_kood");
            if (clazz.AudiitorettevotjaKood!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.AudiitorettevotjaKood))).ToString());
            }
            else {
                Writer.WriteAttributeString("xsi", "nil", null, "1");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("auditit_kpv");
            Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "date");
            Writer.WriteString(new global::Xtee.Core.Schema.XsdDate(((System.DateTime)(clazz.AudititKpv))).ToString());
            Writer.WriteEndElement();
        }
        
        public override void ReadXml(global::Xtee.Core.IXteeXmlReader Reader) {
            base.ReadXml(Reader);
            if (Reader.LocalName=="isikukood") {
                if ((Reader.IsElementNil() == false)) {
                    clazz.Isikukood = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("isikukood")).Value;
                }
                else {
                    Reader.Skip();
                }
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>xbrlesita_audiitor>isikukood", Reader.LocalName);
            }
            if (Reader.LocalName=="audiitorettevotja_kood") {
                if ((Reader.IsElementNil() == false)) {
                    clazz.AudiitorettevotjaKood = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("audiitorettevotja_kood")).Value;
                }
                else {
                    Reader.Skip();
                }
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>xbrlesita_audiitor>audiitorettevotja_kood", Reader.LocalName);
            }
            if (Reader.LocalName=="auditit_kpv") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>xbrlesita_audiitor>auditit_kpv");
                }
                clazz.AudititKpv = new global::Xtee.Core.Schema.XsdDate(Reader.ReadElementString("auditit_kpv")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>xbrlesita_audiitor>auditit_kpv", Reader.LocalName);
            }
        }
    }
}
